package com.party.core.service.school.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.school.ScStudentReadDao;
import com.party.core.dao.write.school.ScStudentWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.school.ScStudent;
import com.party.core.service.school.IScStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

@Service
public class ScStudentService implements IScStudentService {

    @Autowired
    private ScStudentReadDao scStudentReadDao;

    @Autowired
    private ScStudentWriteDao scStudentWriteDao;

    @Override
    public String insert(ScStudent scStudent) {
        BaseModel.preInsert(scStudent);
        if (scStudentWriteDao.insert(scStudent)) {
            return scStudent.getId();
        }
        return null;
    }

    @Override
    public boolean update(ScStudent scStudent) {
        scStudent.setUpdateDate(new Date());
        return scStudentWriteDao.update(scStudent);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return scStudentWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ScStudent get(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return null;
        }
        return scStudentReadDao.get(id);
    }

    @Override
    public List<ScStudent> listPage(ScStudent scStudent, Page page) {
        return scStudentReadDao.listPage(scStudent, page);
    }

    @Override
    public List<ScStudent> list(ScStudent scStudent) {
        return scStudentReadDao.listPage(scStudent, null);
    }

    @Override
    public List<ScStudent> batchList(Set<String> ids, ScStudent scStudent, Page page) {
        return null;
    }
}
